import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 数据列表
export function listData() {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
    }
    return request({
      url: '/getInstitutionsList',
      method: 'post',
      data: data
    })
}

// 新增
export function addData(val) {
  const data = {
    projectContent:{
      ascriptionId: store.state.userInfo.ascriptionId,
      theType: val.theType, //企业类型 1-平台企业 2-外委单位
      fullName: val.fullName, //企业全称
      shorterName: val.shorterName, //企业简称
      logo: val.logo, //LOGO
      tradeId: val.tradeId, //所属行业 id
      trade: val.trade, //所属行业的文字值 （例如：煤炭）
      website: val.website, //企业网址
      realmName: val.realmName, //企业域名
      status: val.status, //启用状态 0-未启用 1-已启用
      cid: val.cid, //企业ID
      license: val.license, //企业营业执照
      creditCode: val.creditCode, //企业信用代码
      address: val.address, //企业地址
      contacts: val.contacts, //企业联系人
      phone: val.phone, //联系电话
      synopsis: val.synopsis //企业简介
    }
  }
  return request({
    url: '/addInstitutions',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid: theid,
    idType: 2, //id类型 1-字符 2-数字
  }
  return request({
    url: '/getInstitutionsData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent:{
      theid: val.theid, //id  18abffeaf91c545b9db43d1f940fb979'
      idType: 2, //id类型 1-字符 2-数字
      fullName: val.fullName, //企业全称
      shorterName: val.shorterName, //企业简称
      logo: val.logo, //LOGO
      tradeId: val.tradeId, //所属行业 id
      trade: val.trade, //所属行业的文字值 （例如：煤炭）
      website: val.website, //企业网址
      realmName: val.realmName, //企业域名
      status: val.status, //启用状态 0-未启用 1-已启用
      cid: val.cid, //企业ID
      license: val.license, //企业营业执照
      creditCode: val.creditCode, //企业信用代码
      address: val.address, //企业地址
      contacts: val.contacts, //企业联系人
      phone: val.phone, //联系电话
      synopsis: val.synopsis //企业简介
    }
  }
  return request({
    url: '/updateInstitutions',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delInstitutions',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleInstitutions',
    method: 'post',
    data: data
  })
}

// 修改启用状态  enable 启用状态  0-未启用 1-已启用
export function getEnable(theid, enable) {
  const data = {
    projectContent: {
      theid: theid, 
      enable: enable
    }
  }
  return request({
    url: '/changeEnableInstitutions',
    method: 'post',
    data: data
  })
}